package com.tanhua.dubbo.server.service;

import com.tanhua.dubbo.server.vo.IdType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class IdService {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    /**
     * 提供redis缓存自增的功能
     */
    public Long creatIncrement(IdType idType){
        String RedisKey = "TANHUA_ID_"+idType.toString();
        return redisTemplate.opsForValue().increment(RedisKey);
    }
}
